package com.奇技淫巧;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.*;

public class Log {

    public static void main(String[] args) {
        try{
            String logPath = "C:\\Users\\admin\\Desktop\\server-2024-09-11.0.log";
            InputStreamReader inputStreamReader = new InputStreamReader(new FileInputStream(logPath), Charset.forName("UTF-8"));
            BufferedReader reader = new BufferedReader(inputStreamReader);
            String line;
            Map<String, Integer> logMap = new HashMap<>();
            while ((line = reader.readLine())!=null){
                if(line.contains("https://dopen.weimob.com")){
                    System.out.println(line);
                    String key = line.substring(line.indexOf("https://dopen.weimob.com"),line.indexOf("?"));
                    Integer num = logMap.get(key);
                    if(num==null){
                        logMap.put(key,1);
                    }else{
                        logMap.put(key,num+1);
                    }
                }
            }
            for(String key : logMap.keySet()){
                System.out.print(key+"=");
                System.out.println(logMap.get(key));
            }
        }catch (Exception ex){
        }
    }

}
